home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5741 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1010 b 

  1. Path: frco.com!usenet
  2. From: Jadam@tcmail.frco.com (Jim Adam)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Help a newbie with a problem....
  5. Date: 6 Feb 1996 16:46:58 GMT
  6. Organization: Fisher Rosemount Systems
  7. Message-ID: <4f80m2$692@rolaids.frco.com>
  8. References: <311527bc.180318@news.deltanet.com>
  9. NNTP-Posting-Host: primrose.frco.com
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.93.11
  12.  
  13. In article <311527bc.180318@news.deltanet.com>, kkhan@deltanet.com says...
  14.  
  15. >Ok I have no clue as to what is wrong with this statement, I have
  16. >tried various forms with no success. The statement is supposed to give
  17. >me a factorial result with this formula :  (n - r + 1) / r.
  18.  
  19.   [ snip ]
  20.  
  21. >       for ( int r = 1; r <= sel; r++)
  22. >       {
  23. >          combo = 1;
  24. >          for ( int fact = ( (num - r + 1) / r ); fact <= r; fact++)
  25. >          { combo *= fact; }
  26. >
  27. >       }
  28. >    cout << endl << "Odds of winning: 1 in " << combo;
  29. >}
  30.  
  31. Shouldn't the "combo = 1" statement come *before* the first for() loop?
  32.  
  33. Jim
  34. Jadam@tcmail.frco.com
  35.  
  36.  
  37.